package me.zk.practice1.s;

/**
 * @author zhangkai
 * @date 2023/7/29 11:28
 */
public class LS29 {
    public static int divide(int dividend, int divisor) {

        if (dividend == Integer.MIN_VALUE && divisor==-1) {
            return Integer.MAX_VALUE;
        }
        if (dividend == Integer.MIN_VALUE && divisor==1) {
            return Integer.MIN_VALUE;
        }
        int flag = divisor > 0 ? 1: -1;
        int i = 0;
        divisor = Math.abs(divisor);
        int res = 0;
        while (res <= dividend) {
            res += divisor;
            i++;
        }
        return (i-1)*flag;
    }

    public static void main(String[] args) {
        System.out.println(divide(10,3));
    }
}
